﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MapLibrary.Utility;

namespace MapLibrary.Particles.Emitters
{
    /// <summary>
    /// This is a particle emitter that will release particles
    /// at a certain frequency.
    /// </summary>
    public abstract class TimedParticleEmitter
    {
        protected ParticleManager particleManager;

        protected TimerUtility emissionTimer;
        protected int framesPerEmission;

        public TimedParticleEmitter(ParticleManager pManager)
        {
            particleManager = pManager;
            emissionTimer = new TimerUtility();
        }

        public void Initialize(int framesPerEmission)
        {
            this.framesPerEmission = framesPerEmission;
            emissionTimer = new TimerUtility(Emit, framesPerEmission);
        } 

        /// <summary>
        /// Update the emitter.  This involves seeing if enough time has passed
        /// to emit a new particle.  If it has, then call the Emit() method.
        /// </summary>
        public void Update()
        {
            emissionTimer.Update();
        }

        /// <summary>
        /// Send the particle(s) out into the world.
        /// </summary>
        protected abstract void Emit();
    }
}
